<include file="Public:header" />
<style>
table tbody tr{cursor:move;}
</style>
	<div class="container">
		<div class="page-header">
			<h4>{:L('THE_MENU_SETTINGS')}</h4>
		</div>
		<include file="Public:alert" />
		
		
		<ul class="nav nav-tabs">
			<li <if condition="$_GET['type'] neq 'simple'">class="active"</if>><a href="#tab1" data-toggle="tab">{:L('NAVIGATION_MENU_SETTINGS')}</a></li>
			<li <if condition="$_GET['type'] eq 'simple'">class="active"</if>><a href="#tab2" data-toggle="tab">{:L('QUICKLY_ADD_MENU_SETTINGS')}</a></li>
		</ul>
		<div class="tab-content">
			<div class="tab-pane <if condition="$_GET['type'] neq simple">active</if>" id="tab1">
				<div class="row">
					<div class="span12">
						<div class="nav pull-left">
							<input type="button" id="sort_btn" class="btn" value="{:L('SAVE_THE_LOCATION')}"/>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="span4" id="postion_top">
						<h4>{:L('NAVIGATION_LOCATION_AT_THE_TOP')}</h4>
						<table class="table table-hover">
							<thead>
								<tr>
								   <th width="25%">{:L('MENU')}</th>
								   <th>{:L('LINK')}</th>						   
								</tr>
							</thead>
							<tbody>
								<empty name="postion.top">
								<tr><td colspan="2">{:L('THIS_POSITION_IS_NOT_TO_ADD_THE_MENU')}</td></tr>
								<else />
									<volist name = "postion.top" id="vo">
										<if condition="$vo.title neq ''">
										<tr>
											<td><input type="hidden" class="list" name="list[]" value="{$vo.id}"/>{$vo.title}</td>
											<td><a href="{$vo.url}" target="_blank"><if condition="strlen($vo['url']) gt 40">{$vo.url|substr=0,40}...<else/>{$vo.url}</if></a></td>
										</tr>
										</if>
									</volist>
								</empty>
								<tr>
									<td colspan="2">&nbsp;</td>
								</tr>
							</tbody>
						</table>
					</div>
					<div class="span4" id="postion_more">
						<h4>{:L('NAVIGATION_LOCATION_MORE')}</h4>
						<table class="table table-hover">
							<thead>
								<tr>
								   <th width="25%">{:L('MENU')}</th>
								   <th>{:L('LINK')}</th>						   
								</tr>
							</thead>
							<tbody>
								<empty name="postion.more">
								<tr><td colspan="2">{:L('THIS_POSITION_IS_NOT_TO_ADD_THE_MENU')}</td></tr>
								<else />
								<volist name = "postion.more" id="vo">
									<if condition="$vo.title neq ''">
									<tr>
										<td><input type="hidden" class="list" name="list[]" value="{$vo.id}"/>{$vo.title}</td>
										<td><a href="{$vo.url}" target="_blank"><if condition="strlen($vo['url']) gt 40">{$vo.url|substr=0,40}...<else/>{$vo.url}</if></a></td>
									</tr>
									</if>
								</volist>
								</empty>
								<tr>
									<td colspan="2">&nbsp;</td>
								</tr>
							</tbody>
						</table>
					</div>
					<div class="span4" id="postion_user">
						<h4>{:L('NAVIGATION_LOCATION_PERSONAL_CENTER')}</h4>
						<table class="table table-hover">
							<thead>
								<tr>
								   <th width="25%">{:L('MENU')}</th>
								   <th>{:L('LINK')}</th>						   
								</tr>
							</thead>
							<tbody>
								<empty name="postion.user">
								<tr><td colspan="2">{:L('THIS_POSITION_IS_NOT_TO_ADD_THE_MENU')}</td></tr>
								<else />
								<volist name = "postion.user" id="vo">
									<if condition="$vo.title neq ''">
									<tr>
										<td><input type="hidden" class="list" name="list[]" value="{$vo.id}"/>{$vo.title}</td>
										<td><a href="{$vo.url}" target="_blank"><if condition="strlen($vo['url']) gt 40">{$vo.url|substr=0,40}...<else/>{$vo.url}</if></a></td>
									</tr>
									</if>
								</volist>
								</empty>
								<tr>
									<td colspan="2">&nbsp;</td>
								</tr>
							</tbody>
						</table>
					</div>
				</div>
			</div>
			<div class="tab-pane <if condition="$_GET['type'] eq 'simple'">active</if>" id="tab2">
				<div class="row">
					<div class="span12">
						<div class="nav pull-left">
							<input type="button" id="menu_sort_btn" class="btn" value="{:L('SAVE_THE_LOCATION')}"/>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="span4" id="menu_select">
						<h4>{:L('THE_SELECTED_OPTIONS')}</h4>
						<table class="table table-hover">
							<thead>
								<tr>
								   <th width="25%">{:L('MENU')}</th>
								   <th>{:L('LINK')}</th>						   
								</tr>
							</thead>
							<tbody>
								<empty name="simple_menu">
								<tr><td colspan="2">{:L('THIS_POSITION_IS_NOT_TO_ADD_THE_MENU')}</td></tr>
								<else />
								<volist name = "simple_menu" id="vo">
									<tr>
										<td><input type="hidden" class="menu" name="menu[]" value="{$vo.module}"/>{$vo.module_name}</td>
										<td><a href="{$vo.url}" target="_blank">{$vo.url}</a></td>
									</tr>
								</volist>	
								</empty>
								<tr>
									<td colspan="2">&nbsp;</td>
								</tr>
							</tbody>
						</table>
					</div>
					<div class="span2" style="margin-top: 100px;text-align: center;">
						<p><img src="__PUBLIC__/img/left_arrow.png"/></p><p style="text-align:left;">{:L('PLEASE_SEND_THE_RIGHT')}</p>
					</div>
					<div class="span4" id="menu_all">
						<h4>{:L('ALL_THE_OPTIONS')}</h4>
						<table class="table table-hover">
							<thead>
								<tr>
								   <th width="25%">{:L('MENU')}</th>
								   <th>{:L('LINK')}</th>						   
								</tr>
							</thead>
							<tbody>
								<tr>
									<td><input type="hidden" class="menu" name="menu[]" value="log"/>{:L('LOG')}</td>
									<td>/index.php?m=log&a=mylog_add</td>
								</tr>
								<tr>
									<td><input type="hidden" class="menu" name="menu[]" value="business"/>{:L('BUSINESS')}</td>
									<td>/index.php?m=business&a=add</td>
								</tr>
								<tr>
									<td><input type="hidden" class="menu" name="menu[]" value="knowledge"/>{:L('KNOWLEDGE')}</td>
									<td>/index.php?m=knowledge&a=add</td>
								</tr>
								<tr>
									<td><input type="hidden" class="menu" name="menu[]" value="product"/>{:L('PRODUCT')}</td>
									<td>/index.php?m=product&a=add</td>
								</tr>
								<tr>
									<td><input type="hidden" class="menu" name="menu[]" value="customer"/>{:L('CUSTOMER')}</td>
									<td>/index.php?m=customer&a=add</td>
								</tr>
								<tr>
									<td><input type="hidden" class="menu" name="menu[]" value="contacts"/>{:L('CONTACTS')}</td>
									<td>/index.php?m=contacts&a=add</td>
								</tr>
								<tr>
									<td><input type="hidden" class="menu" name="menu[]" value="announcement"/>{:L('ANNOUNCEMENT')}</td>
									<td>/index.php?m=announcement&a=add</td>
								</tr>
								<tr>
									<td><input type="hidden" class="menu" name="menu[]" value="event"/>{:L('EVENT')}</td>
									<td>/index.php?m=event&a=add</td>
								</tr>
								<tr>
									<td><input type="hidden" class="menu" name="menu[]" value="contract"/>{:L('CONTRACT')}</td>
									<td>/index.php?m=contract&a=add</td>
								</tr>
								<tr>
									<td><input type="hidden" class="menu" name="menu[]" value="task"/>{:L('TASK')}</td>
									<td>/index.php?m=task&a=add</td>
								</tr>
								<tr>
									<td><input type="hidden" class="menu" name="menu[]" value="receivables"/>{:L('THE_ACCOUNTS_RECEIVABLE')}</td>
									<td>/index.php?m=finance&a=add&t=receivables</td>
								</tr>
								<tr>
									<td><input type="hidden" class="menu" name="menu[]" value="payables"/>{:L('THE_ACCOUNTS_PAYABLE')}</td>
									<td>/index.php?m=finance&a=add&t=payables</td>
								</tr>
								<tr>
									<td><input type="hidden" class="menu" name="menu[]" value="receivingorder"/>{:L('VOUCHER')}</td>
									<td>/index.php?m=finance&a=add&t=receivingorder</td>
								</tr>
								<tr>
									<td><input type="hidden" class="menu" name="menu[]" value="paymentorder"/>{:L('PAYMENT_ORDER')}</td>
									<td>/index.php?m=finance&a=add&t=paymentorder</td>
								</tr>
								<tr>
									<td colspan="2">&nbsp;</td>
								</tr>
								</tbody>
						</table>
					</div>
				</div>
			</div>
		</div>
	</div>
<script type="text/javascript">
	$(function(){
		$("table tbody").sortable({connectWith: "table tbody"});
		$("#sort_btn").click(
			function() {
				var postion_top = new Array();
				$.each($("#postion_top .list"), function(i, item){postion_top.push(item.value)});
				var postion_user = new Array();
				$.each($("#postion_user .list"), function(i, item){postion_user.push(item.value)});
				var postion_more = new Array();
				$.each($("#postion_more .list"), function(i, item){postion_more.push(item.value)});
				$.get('{:U("navigation/index")}',{postion_top:postion_top.join(','), postion_user:postion_user.join(','), postion_more:postion_more.join(',')}, function(data){
					if (data.status == 1) {
						$(".page-header").after('<div class="alert alert-success"><button type="button" class="close" data-dismiss="alert">×</button>' + data.info + '</div>');
					} else {
						$(".page-header").after('<div class="alert alert-error"><button type="button" class="close" data-dismiss="alert">×</button>' + data.info + '</div>');
					}
				}, 'json');
			}		
		);
		$("#menu_sort_btn").click(
			function() {
				var menu_select = new Array();
				$.each($("#menu_select .menu"), function(i, item){menu_select.push(item.value)});
				
				$.get('{:U("navigation/settingMenu")}',{menu_select:menu_select.join(',')}, function(data){
					if (data.status == 1) {
						$(".page-header").after('<div class="alert alert-success"><button type="button" class="close" data-dismiss="alert">×</button>' + data.info + '</div>');
					} else {
						$(".page-header").after('<div class="alert alert-error"><button type="button" class="close" data-dismiss="alert">×</button>' + data.info + '</div>');
					}
				}, 'json');
			}		
		);
	});
</script>
<include file="Public:footer" />